package io.renren.modules.app.service.impl;

import io.renren.modules.app.utils.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.app.dao.ProductCategoryDao;
import io.renren.modules.app.entity.ProductCategoryEntity;
import io.renren.modules.app.service.ProductCategoryService;


@Service("productCategoryService")
public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryDao, ProductCategoryEntity> implements ProductCategoryService {

    /**
     * 分页获取商品分类
     *
     * @param params
     * @return
     */
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String key = String.valueOf(params.get("key"));
        QueryWrapper<ProductCategoryEntity> wrapper = new QueryWrapper<>();
        if (StringUtils.isNotEmpty(key)) {
            wrapper.like("category_name", key);
        }
        IPage<ProductCategoryEntity> page = this.page(new Query<ProductCategoryEntity>().getPage(params), wrapper);
        return new PageUtils(page);
    }

}